package com.matrix.draft.jvm.jmm;

/**
 * 懒汉单例可能出现的指令重排
 */
public class JITSingleton {
    private volatile static JITSingleton INSTANCE = null;

    private JITSingleton() {
    }

    public static JITSingleton getInstance() {
        if (null == INSTANCE) {
            synchronized (JITSingleton.class) {
                if (null == INSTANCE) {
                    INSTANCE = new JITSingleton(); // 有指令重排风险
                }
            }
        }
        return INSTANCE;
    }
}
